// Menubutton
// Creates a menu button that checks the position of the mouse cursor and 
// returns whether or not the cursor is hovering over the graphic.
// Can then use this information to change the state of the button
// i.e. is it highlighted or not.

#pragma once

#include <d3d9.h>
#include <d3dx9.h>

#include "MenuGlobals.h"
#include "ButtonTypes.h"

#define TEXTCOLOR_PRESSED	D3DCOLOR_ARGB(255, 0, 0, 0)
#define TEXTCOLOR_UNPRESSED	D3DCOLOR_ARGB(255, 0, 0, 0)

class MenuButton
{
protected:
	//D3DXVECTOR3			mScreenPosition;
	D3DXVECTOR3			mCenter;
	ID3DXFont*			mFont;
	ID3DXSprite*		mSprite;
	IDirect3DTexture9*	mTextureLit;
	IDirect3DTexture9*	mTextureUnlit;

	bool				mHighlighted;
	bool				mActivated;
	char				mTextBuffer[64];

	float				mScreenW;
	float				mScreenH;

	float				mLeft;
	float				mRight;
	float				mTop;
	float				mBottom;

	float				mHeight;
	float				mWidth;

	ButtonType			idNum;

public:
	MenuButton(ButtonType id, float xLeft, float xRight, float yTop, float yBottom,
		int w, 
		int h, 
		LPCSTR texLit, 
		LPCSTR texUnlit, 
		ID3DXSprite* sprite, 
		ID3DXFont* font);
	MenuButton();
	~MenuButton();

	
protected:
	// returns whether the cursor is over the graphic or not
	bool IsMouseOver(POINT mousepos);

	// change the state of the button
	void Highlight(void)	{mHighlighted = true;};
	void Darken(void)		{mHighlighted = false;};
	void Activate(void)		{mActivated = true;};
	void Deactivate(void)	{mActivated = false;};

public:
	// renders the button to the screen
	virtual void Render(void);

	// set the position of the button. Needed when we change screen format
	// and need to update the button with a new position relative to the top-left point
	// of the screen
	void OnResetDevice(float bbWidth, float bbHeight);

	virtual bool Update(POINT mousepos, bool buttonDown) = 0;

	UINT GetID(void) {return idNum;};
};